<template>
    <view class="page-person bg-content">
        <view class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30" style="padding-top: 15px; margin-bottom: 10px; !important;">
            <view class="u-m-r-10" @click="navigateTo(`/pages/sub/sub1-tabs/tabs/person/setting/setting-my-info/index`)">
                <!--<myImg :obj="globalVariable.userInfo" :sysFile="{fkId: globalVariable.userInfo.id}" class="picture"-->
                <!--:customStyle="'pointer-events: none; height: 80px; width: 80px; border-radius: 50%; background-size: cover; background-repeat: no-repeat; background-position: center;'"-->
                <!--:defaultUrl="'/pages/sub/sub1-tabs/static/default-image/user-avatar.png'" :imageView="'imageView2/1/w/80/h/80'"></myImg>-->

                <image :src="'/pages/sub/sub1-tabs/static/default-image/user-avatar.png'" style="width: 100px; height: 100px;"></image>
            </view>
            <view class="u-flex-1">
                <view class="u-font-18 u-p-b-20" @click="navigateTo(`/pages/sub/sub1-tabs/tabs/person/setting/setting-my-info/index`)">
                    {{globalVariable.userInfo.username}}
                </view>
                <view class="u-font-14 u-tips-color">
                    <div v-if="globalVariable.userInfo.customerName" style="color: red;">
                        选中客户：{{globalVariable.userInfo.customerName}}
                    </div>
                </view>
            </view>
            <!--<view class="u-m-l-10 u-p-10">-->
            <!--<u-icon name="scan" color="#969799" size="28"></u-icon>-->
            <!--</view>-->
            <!--<view class="u-m-l-10 u-p-10">-->
            <!--<u-icon name="arrow-right" color="#969799" size="28"></u-icon>-->
            <!--</view>-->
        </view>

        <view v-if="isShowMyOrder" style="background-color: #ffffff; margin-bottom: 10px; !important;">
            <u-cell-item :title="myOrderTitle" :arrow="false">
                <div @click="navigateTo('/pages/sub/sub1-tabs/tabs/person/order/index?activeTabIndex=0')">
                    查看全部订单
                    <u-icon slot="right-icon" name="arrow-right"></u-icon>
                </div>
            </u-cell-item>

            <div class="table text-center preference" style="table-layout: fixed;"
                 v-bind:class="{ fullOrder: globalVariable.userInfo.tbCommunity.isOpenStore }">
                <div class="tr">
                    <div class="td" @click="navigateTo('/pages/sub/sub1-tabs/tabs/person/order/index?activeTabIndex=1')">
                        <image class="title-icon" src="/pages/sub/sub1-tabs/static/icon/tabs/person/pay.png"></image>
                        <div class="title">待付款</div>
                    </div>
                    <div class="td" @click="navigateTo('/pages/sub/sub1-tabs/tabs/person/order/index?activeTabIndex=2')">
                        <image class="title-icon" src="/pages/sub/sub1-tabs/static/icon/tabs/person/send.png"></image>
                        <div class="title">待发货</div>
                    </div>
                    <div class="td" @click="navigateTo('/pages/sub/sub1-tabs/tabs/person/order/index?activeTabIndex=3')">
                        <image class="title-icon" src="/pages/sub/sub1-tabs/static/icon/tabs/person/deliver.png"></image>
                        <div class="title">待收货</div>
                    </div>
                    <div class="td" @click="navigateTo('/pages/sub/sub1-tabs/tabs/person/order/index?activeTabIndex=4')">
                        <image class="title-icon" src="/pages/sub/sub1-tabs/static/icon/tabs/person/canceled.png"></image>
                        <div class="title">已取消</div>
                    </div>
                    <div class="td" @click="navigateTo('/pages/sub/sub1-tabs/tabs/person/order/index?activeTabIndex=5')">
                        <image class="title-icon" src="/pages/sub/sub1-tabs/static/icon/tabs/person/edit.png"></image>
                        <div class="title">待评价</div>
                    </div>
                </div>
            </div>
        </view>

        <view v-if="isShowConsumerVoucher" style="background-color: #ffffff; margin-bottom: 10px; !important;">
            <u-cell-item :title="consumerVoucherTitle" :arrow="false">
                <div @click="navigateTo('/pages/sub/sub1-tabs/tabs/person/consumer-voucher/index?activeTabIndex=0')">
                    查看全部订单
                    <u-icon slot="right-icon" name="arrow-right"></u-icon>
                </div>
            </u-cell-item>

            <div class="table text-center preference" style="table-layout: fixed;">
                <div class="tr">
                    <div class="td" @click="navigateTo('/pages/sub/sub1-tabs/tabs/person/consumer-voucher/index?activeTabIndex=1')">
                        <image class="title-icon" src="/pages/sub/sub1-tabs/static/icon/tabs/person/round_ticket.png"></image>
                        <div class="title">未支付</div>
                    </div>
                    <div class="td" @click="navigateTo('/pages/sub/sub1-tabs/tabs/person/consumer-voucher/index?activeTabIndex=2')">
                        <image class="title-icon" src="/pages/sub/sub1-tabs/static/icon/tabs/person/unused.png"></image>
                        <div class="title">未使用</div>
                    </div>
                    <div class="td" @click="navigateTo('/pages/sub/sub1-tabs/tabs/person/consumer-voucher/index?activeTabIndex=3')">
                        <image class="title-icon" src="/pages/sub/sub1-tabs/static/icon/tabs/person/used.png"></image>
                        <div class="title">已使用</div>
                    </div>
                    <div class="td" @click="navigateTo('/pages/sub/sub1-tabs/tabs/person/consumer-voucher/index?activeTabIndex=4')">
                        <image class="title-icon" src="/pages/sub/sub1-tabs/static/icon/tabs/person/canceled.png"></image>
                        <div class="title">已取消</div>
                    </div>
                    <div class="td" @click="navigateTo('/pages/sub/sub1-tabs/tabs/person/consumer-voucher/index?activeTabIndex=5')">
                        <image class="title-icon" src="/pages/sub/sub1-tabs/static/icon/tabs/person/edit.png"></image>
                        <div class="title">待评价</div>
                    </div>
                </div>
            </div>
        </view>

        <view v-if="isShowEateryOrder" style="background-color: #ffffff; margin-bottom: 10px; !important;">
            <u-cell-item :title="eateryOrderTitle" :arrow="false">
                <div @click="navigateTo('/pages/sub/sub1-tabs/tabs/person/eatery-order/index?activeTabIndex=0')">
                    查看全部订单
                    <u-icon slot="right-icon" name="arrow-right"></u-icon>
                </div>
            </u-cell-item>

            <div class="table text-center preference" style="table-layout: fixed;">
                <div class="tr">
                    <div class="td" @click="navigateTo('/pages/sub/sub1-tabs/tabs/person/eatery-order/index?activeTabIndex=1')">
                        <image class="title-icon" src="/pages/sub/sub1-tabs/static/icon/tabs/person/round_ticket.png"></image>
                        <div class="title">未支付</div>
                    </div>
                    <div class="td" @click="navigateTo('/pages/sub/sub1-tabs/tabs/person/eatery-order/index?activeTabIndex=2')">
                        <image class="title-icon" src="/pages/sub/sub1-tabs/static/icon/tabs/person/unused.png"></image>
                        <div class="title">已支付</div>
                    </div>
                    <div class="td" @click="navigateTo('/pages/sub/sub1-tabs/tabs/person/eatery-order/index?activeTabIndex=3')">
                        <image class="title-icon" src="/pages/sub/sub1-tabs/static/icon/tabs/person/used.png"></image>
                        <div class="title">已完成</div>
                    </div>
                    <div class="td" @click="navigateTo('/pages/sub/sub1-tabs/tabs/person/eatery-order/index?activeTabIndex=4')">
                        <image class="title-icon" src="/pages/sub/sub1-tabs/static/icon/tabs/person/canceled.png"></image>
                        <div class="title">已取消</div>
                    </div>
                    <div class="td" @click="navigateTo('/pages/sub/sub1-tabs/tabs/person/eatery-order/index?activeTabIndex=5')">
                        <image class="title-icon" src="/pages/sub/sub1-tabs/static/icon/tabs/person/edit.png"></image>
                        <div class="title">待评价</div>
                    </div>
                </div>
            </div>
        </view>

        <view style="background-color: #ffffff; margin-bottom: 10px; !important;">
            <div class="table text-center preference" style="table-layout: fixed;">
                <div class="tr">
                    <div class="td" @click="navigateTo('/pages/sub/sub1-tabs/tabs/person/coupon/index')">
                        <image class="title-icon" src="/pages/sub/sub1-tabs/static/icon/tabs/person/ticket.png"></image>
                        <div class="title">优惠券</div>
                    </div>
                    <div class="td" @click="navigateTo('/pages/sub/sub1-tabs/tabs/person/collect-user-goods/index')">
                        <image class="title-icon" src="/pages/sub/sub1-tabs/static/icon/tabs/person/goods_favor.png"></image>
                        <div class="title">商品收藏</div>
                    </div>
                    <div class="td" @click="navigateTo('/pages/sub/sub1-tabs/tabs/person/collect-user-store/index')">
                        <image class="title-icon" src="/pages/sub/sub1-tabs/static/icon/tabs/person/like.png"></image>
                        <div class="title">店铺收藏</div>
                    </div>
                    <div class="td" @click="navigateTo('/pages/sub/sub1-tabs/tabs/person/goods-after-sale/index?activeTabIndex=0')">
                        <image class="title-icon" src="/pages/sub/sub1-tabs/static/icon/tabs/person/refund.png"></image>
                        <div class="title">退换/售后</div>
                    </div>
                    <div class="td" @click="navigateTo('/pages/sub/sub1-tabs/tabs/person/goods-comment/index')">
                        <image class="title-icon" src="/pages/sub/sub1-tabs/static/icon/tabs/person/edit.png"></image>
                        <div class="title">我的评价</div>
                    </div>
                </div>
            </div>
        </view>

        <view class="u-m-t-20">
            <u-cell-group>
                <u-cell-item icon="map" title="收货地址"
                             @click="navigateTo('/pages/sub/sub1-tabs/tabs/person/shipping-address/index')"></u-cell-item>
                <u-cell-item icon="question-circle" title="常见问题" @click="navigateTo(`/pages/sub/sub1-tabs/tabs/person/faq/index`)"></u-cell-item>
                <u-cell-item icon="edit-pen" title="意见反馈" @click="navigateTo(`/pages/sub/sub1-tabs/tabs/person/feedback/index`)"></u-cell-item>
                <u-cell-item icon="scan" title="切换商城" :value="globalVariable.userInfo.tbCommunity.name" v-if="globalVariable.userInfo.username !== 'tgh004005'"
                             @click="navigateTo(`/pages/sub/sub1-tabs/tabs/person/switch-community/index`)"></u-cell-item>

                <!--<u-cell-item icon="star" title="收藏"></u-cell-item>-->
                <!--<u-cell-item icon="photo" title="相册"></u-cell-item>-->
                <!--<u-cell-item icon="coupon" title="卡券"></u-cell-item>-->
                <!--<u-cell-item icon="heart" title="关注"></u-cell-item>-->
            </u-cell-group>
        </view>

        <view class="u-m-t-20">
            <u-cell-group>
                <u-cell-item icon="grid" title="商户平台" v-if="isShowStorePlatform" @click="navigateTo(`/pages/sub/sub2-store-platform/store-platform/index`)"></u-cell-item>
                <u-cell-item icon="grid" title="商城平台" @click="navigateTo(`/pages/sub/sub3-community-platform/community-platform/index`)"></u-cell-item>
            </u-cell-group>
        </view>

        <view class="u-m-t-20">
            <u-cell-group>
                <u-cell-item icon="setting" title="设置" @click="navigateTo(`/pages/sub/sub1-tabs/tabs/person/setting/index`)"></u-cell-item>
            </u-cell-group>
        </view>

        <div style="margin-bottom: 10px;">
            <official-account style="width: 100%;"></official-account>
        </div>

        <div style="height: 60px;"></div>

        <!--<view class="u-m-t-20">-->
        <!--<u-cell-group>-->
        <!--</u-cell-group>-->
        <!--</view>-->
    </view>
</template>

<script>

    import myImg from '@/components/my-img'

    export default {
        data() {
            return {
                isShowMyOrder: false,  //是否显示我的订单
                myOrderTitle: '我的订单',

                isShowConsumerVoucher: false,  //是否显示消费券
                consumerVoucherTitle: '我的订单',

                isShowEateryOrder: false,  //是否显示餐饮店订单
                eateryOrderTitle: '我的订单',

                isShowStorePlatform: false,  //是否显示卖家中心
                isShowCommunityPlatform: false  //是否显示商城中心
            }
        },
        components: {
            myImg
        },
        mounted() {
            const _self = this;

            // 类型：0-公共商城，1-封闭商城（自定义），2-公司&业务员模式，3-公司&客户模式，4-公司&业务员模式&客户模式
            if (this.globalVariable.userInfo.tbCommunity.type === null || this.globalVariable.userInfo.tbCommunity.type === "0") {

                this.isShowMyOrder = true;
                this.myOrderTitle = '我的物流订单';

                this.isShowConsumerVoucher = true;
                this.consumerVoucherTitle = '我的消费券';

                this.isShowEateryOrder = true;
                this.eateryOrderTitle = '我的餐饮订单';

            } else if (this.globalVariable.userInfo.tbCommunity.type === "1") {
                // 自定义商城，如果开放开店模式，则显示所有。否则显示商城管理员销售模式
                if (this.globalVariable.userInfo.tbCommunity.isOpenStore) {
                    this.isShowMyOrder = true;
                    this.myOrderTitle = '我的物流订单';

                    this.isShowConsumerVoucher = true;
                    this.consumerVoucherTitle = '我的消费券';

                    this.isShowEateryOrder = true;
                    this.eateryOrderTitle = '我的餐饮订单';
                } else {
                    let saleMode = this.globalVariable.userInfo.tbCommunityUser.adminStore.saleMode;
                    if (saleMode === "0") {  // 物流模式
                        this.isShowMyOrder = true;
                        this.isShowConsumerVoucher = false;
                        this.isShowEateryOrder = false;
                    } else if (saleMode === "1") { // 消费券模式
                        this.isShowMyOrder = false;
                        this.isShowConsumerVoucher = true;
                        this.isShowEateryOrder = false;
                    } else if (saleMode === "2") {  // 餐饮店模式
                        this.isShowMyOrder = false;
                        this.isShowConsumerVoucher = false;
                        this.isShowEateryOrder = true;
                    }
                }
            } else if (",2,3,4".indexOf(this.globalVariable.userInfo.tbCommunity.type) !== -1) {  // 公司模式
                // 不开放店铺，则只有管理员才能开店，需要获取管理员店铺的销售模式
                let saleMode = this.globalVariable.userInfo.tbCommunityUser.adminStore.saleMode;
                if (saleMode === "0") {  // 物流模式
                    this.isShowMyOrder = true;
                    this.isShowConsumerVoucher = false;
                    this.isShowEateryOrder = false;
                } else if (saleMode === "1") { // 消费券模式
                    this.isShowMyOrder = false;
                    this.isShowConsumerVoucher = true;
                    this.isShowEateryOrder = false;
                } else if (saleMode === "2") {  // 餐饮店模式
                    this.isShowMyOrder = false;
                    this.isShowConsumerVoucher = false;
                    this.isShowEateryOrder = true;
                }
            }

            if (this.globalVariable.userInfo.tbCommunity.isOpenStore) {
                this.isShowStorePlatform = true;
            }

            if (this.globalVariable.userInfo.tbCommunity.isOpenCommunity) {
                this.isShowCommunityPlatform = true;
            }

            // 超级管理员可以访问卖家中心、商城中心
            if (_self.globalVariable.userInfo.tbCommunityAdmin) {
                _self.isShowStorePlatform = true;
                _self.isShowCommunityPlatform = true;
            }

            // 全部放开测试
            // this.isShowMyOrder = true;
            // this.isShowConsumerVoucher = true;
            // this.isShowEateryOrder = true;
            // this.isShowStorePlatform = true;
            // this.isShowCommunityPlatform = true;
        },
        methods: {}
    }
</script>

<style lang="scss" scoped>
    @import "./index.scss";

    .page-person .my-portrait {
        width: 80px;
        height: 80px;
        border-radius: 50%;
        overflow: hidden;
        display: block;
    }

    .page-person .table.preference {
        background: white;
        padding-top: 10px;
        padding-bottom: 10px;

        .td {
            text-align: center;

            .title-icon {
                width: 28px;
                height: 28px;
            }

            .title {
                padding-top: 5px;
                font-size: 14px
            }
        }
    }

    .page-person .fullOrder {
        border-bottom: 1px solid #ebedf0;
    }
</style>
